<?php
// +----------------------------------------------------------------------
// | CSMITSM  [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 https://www.fastadmin.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: chenshiming
// +----------------------------------------------------------------------

namespace app\admin\controller\csmitsm;

use addons\csmitsm\library\xcore\xcore\base\XcABackend;
use addons\csmitsm\library\xcore\xcore\utils\XcConfigUtils;
use addons\csmitsm\library\xcore\xcore\utils\XcRequestUtils;
use addons\csmitsm\library\xcore\xcore\utils\XcAdminTabUtils;
use addons\csmitsm\library\xcore\xcore\utils\XcRequestPathUtils;

/**
 * 图表页面配置
 *
 * @icon fa fa-circle-o
 */
class Xcflowchartpage extends XcABackend
{

    /**
     * Xcflowchartpage模型对象
     * @var \app\admin\model\csmitsm\Xcflowchartpage
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\csmitsm\Xcflowchartpage;
        $this->assign("statusList", $this->model->getStatusList());

        // csmitsm:设置页面tabs
        $xc_tabid = XcRequestUtils::param(["id", "ids", "xc_tabid"]);
        XcAdminTabUtils::append_control_initialize('xcflowchartpage', $xc_tabid, __CLASS__, $this->view);
    }

    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */
    public function fieldconfig($ids)
    {
        $addoncode = XcConfigUtils::getAddonCode();
        // $xcbaseurl = XcConfigUtils::config("xcbaseurl") . "/addons/{$addoncode}/xc_xcflowchartpage/";
        $xcbaseurl = XcRequestPathUtils::urlAddons("/xc_xcflowchartpage/");
        $param = ["xcform_id" => $ids, "xccontrol" => "xcchart", "xcbaseurl" => $xcbaseurl];

        $url = XcRequestUtils::appendUrlParams("/assets/addons/{$addoncode}/h5_xcflow_xcform/#/", $param);
        $xdebugSrc = XcRequestUtils::appendUrlParams("http://localhost:8080/#/", $param);

        return $this->fetchIframePage($url, $xdebugSrc);
    }

    public function publishmenu()
    {
        return $this->_publishmenu("csmitsm/xcflowviewpageview_instance/detail?xcflowchartpage_id=[[id]]");
    }
}
